package com.wjs.spring.biz;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Aspect
public class LogAspect {
    @Pointcut("execution(* com.wjs.spring.biz..insert*(..))")
    public void insertPointcut(){
    }

    @Pointcut("execution(* com.wjs.spring.biz..delete*(..))")
    public void deletePointcut(){
    }

    @Pointcut("execution(* com.wjs.spring.biz..update*(..))")
    public void updatePointcut(){
    }

    @Before("insertPointcut() || deletePointcut() || updatePointcut()")
    public void beforeService(JoinPoint joinPoint){
        SimpleDateFormat s = new SimpleDateFormat("yyyy年MM月dd hh:mm:ss");
        Date date = new Date();
        String time = s.format(date);
        System.out.println(time + "wjs" + joinPoint.getSignature().getDeclaringTypeName()+" " + joinPoint.getSignature().getName());
    }

}
